<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
</head>

<body>
    <table id="student_subject_scoredg">
        <thead>
            <tr>
                <th data-options="field:'班级',sortable:true">班级</th>
                <th data-options="field:'学号',sortable:true">学号</th>
                <th data-options="field:'姓名',sortable:true">姓名</th>
                <th data-options="field:'语文',sortable:true">语文</th>
                <th data-options="field:'语文名次',sortable:true">语文名次</th>
                <th data-options="field:'数学',sortable:true">数学</th>
                <th data-options="field:'数学名次',sortable:true">数学名次</th>
                <th data-options="field:'英语',sortable:true">英语</th>
                <th data-options="field:'英语名次',sortable:true">英语名次</th>
                <th data-options="field:'物理',sortable:true">物理</th>
                <th data-options="field:'物理名次',sortable:true">物理名次</th>
                <th data-options="field:'化学',sortable:true">化学</th>
                <th data-options="field:'化学名次',sortable:true">化学名次</th>
                <th data-options="field:'政治',sortable:true">政治</th>
                <th data-options="field:'政治名次',sortable:true">政治名次</th>
                <th data-options="field:'历史',sortable:true">历史</th>
                <th data-options="field:'历史名次',sortable:true">历史名次</th>
                <th data-options="field:'政史',sortable:true">政史</th>
                <th data-options="field:'政史名次',sortable:true">政史名次</th>
                <th data-options="field:'体育',sortable:true">体育</th>
                <th data-options="field:'体育名次',sortable:true">体育名次</th>
                <th data-options="field:'总分',sortable:true">总分</th>
                <th data-options="field:'班排',sortable:true">班排</th>
                <th data-options="field:'级排',sortable:true">级排</th>
                <th data-options="field:'上次级排',sortable:true">上次级排</th>
                <th data-options="field:'升幅',formatter(value,row,index){
                    if(!value) return '';
                    if(parseInt(value) > 0) {
                        return '<span style=\'color:#4caf50\'>'+value+'</span>';
                    }else {
                        return '<span style=\'color:#f00\'>'+value+'</span>';
                    }
                    
                }">升幅</th>
            </tr>
        </thead>
    </table>
    <div id="student_subject_scoretb">
        <form id="student_subject_scoreForm" class="m5">
            <div>
                学期：
                <select class="easyui-combobox" name="termId" id="termId" data-options="width:120,panelHeight:'auto',value:'请选择', editable:false,textField:'学期名称',valueField:'ID',url:'/compent/Util/termList',onSelect:changeTerm"></select>
                <select id="gradeId" class="easyui-combobox" data-options="width:80,panelHeight:'auto', editable:false,url:'/compent/Util/gradeNameList',onSelect:changeGrade"></select>
                <select id="examId" class="easyui-combobox" data-options="width:120,panelHeight:'auto',editable:false"></select>
                <select id="clazz" class="easyui-combobox" data-options="width:60,editable:false"></select>
                <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="queryOk('student_subject_score')">查询</a>
                <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-clear'" onclick="resetForm1('student_subject_score')">重置</a>
                <a class="easyui-linkbutton" href="javascript:void(0)" data-options="iconCls:'icon-save'" onclick="zoutExcel('student_subject_score','/examScore/student_subject_score')">导出为EXCEL</a>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $(function(){
            var url = "";
            $("#student_subject_scoredg").datagrid({
                url: "/examScore/student_subject_score/pageQuery.html",
                rownumbers:true,
                striped:true,
                border:false,
                pagination:true,
                pageSize:30,
                fitColumns:true,
                fit:true,
                toolbar: '#student_subject_scoretb'
            })
        })  
        function changeTerm(record){
            var gradeId = $('#gradeId').combobox('getValue');
            loadParam(record.ID,gradeId)
        }
        function changeGrade(record){
            var termId = $('#termId').combobox('getValue');
            loadParam(termId,record.value)
        }
        function loadParam(termId,gradeId) {
            if(!gradeId) return;
            var url="/compent/util/getTermExam?termId="+termId+"&grade="+gradeId;
            $('#examId').combobox('setValue','');
            $('#examId').combobox('reload',url);
            var termName = $('#termId').combobox('getText');
            var termKey = termName.substr(termName,4);
            var grade = getGrade(termKey,gradeId);
            var url="/compent/Util/clazzList?grade="+grade;
            $('#clazz').combobox('setValue','');
            $('#clazz').combobox('reload',url);
        }

        function resetForm1(cf){
            $("#" + cf + "Form")[0].reset();
            $("#" + cf + "Form #termId").combobox('setValue', "请选择");
            $("#" + cf + "Form #gradeId").combobox('setValue', null);
            $("#" + cf + "Form #examId").datebox('setValue', null);
            $("#" + cf + "Form #subject").datebox('setValue', null);
            $("#" + cf + "Form #clazz").datebox('setValue', null);
        }
        function queryOk(){
            var termId = $('#termId').combobox('getValue');
            var examId = $('#examId').combobox('getValue');
            var gradeId = $('#gradeId').combobox('getValue');
            var clazz = $('#clazz').combobox('getValue');
            if(examId && gradeId){
                var termName = $('#termId').combobox('getText');
                var termKey = termName.substr(termName,4);
                var grade = getGrade(termKey,gradeId);
                if(gradeId==1){
                    $('#student_subject_scoredg').datagrid('hideColumn','物理').datagrid('hideColumn','物理名次')
                    .datagrid('hideColumn','化学').datagrid('hideColumn','化学名次');
                } else if(gradeId == 2) {
                    $('#student_subject_scoredg').datagrid('showColumn','物理').datagrid('showColumn','物理名次')
                    .datagrid('hideColumn','化学').datagrid('hideColumn','化学名次');
                } else {
                    $('#student_subject_scoredg').datagrid('showColumn','化学').datagrid('showColumn','化学名次')
                    .datagrid('showColumn','物理').datagrid('showColumn','物理名次');
                }
                $('#student_subject_scoredg').datagrid('load',{grade:grade,gradeId:gradeId,clazz:clazz,examId:examId,termId:termId});
            }else{
                $.messager.alert('操作提示','请选择考试名称和年级。');
            }
        }
        function zoutExcel(cf,url){
            var termId = $('#termId').combobox('getValue');
            var examId = $('#examId').combobox('getValue');
            var gradeId = $('#gradeId').combobox('getValue');
            var clazz = $('#clazz').combobox('getValue');
            if(examId && gradeId){
                var termName = $('#termId').combobox('getText');
                var termKey = termName.substr(termName,4);
                var grade = getGrade(termKey,gradeId);
                window.location.href = url+"/exportExcel.html?grade="+grade+"&gradeId="+gradeId+"&clazz="+clazz+"&examId="+examId+"&termId="+termId;
            }else{
                $.messager.alert('操作提示','请选择考试名称和年级。');
            }
        }
    </script>
</body>
</html>